package com.example.bilderquiz;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.app.Activity;
import android.content.Intent;

public class MainActivity extends Activity implements OnClickListener {
	
	protected Button _buttonSpielStarten = null;
	protected Button _buttonHilfe = null;
	protected DBManager _dbManager = null;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		_buttonSpielStarten=(Button)findViewById(R.id.buttonSpielStarten);
		_buttonHilfe=(Button)findViewById(R.id.buttonHilfe);
		_buttonSpielStarten.setOnClickListener(this);
		_buttonHilfe.setOnClickListener(this);
		
		//DBManager erzeugen
		//_dbManager = new DBManager (this);
	}

	@Override
	public void onClick(View view) {
		
		if (view == _buttonSpielStarten) {
			Intent intent = new Intent(this,FragenActivity.class);
			int [] fragenID= new int[5];
			try {
				_dbManager = new DBManager (this);
				fragenID =  _dbManager.getFrage();
				Log.v("mainActivity", "getFrage erfolgreich");
			} catch (Exception e) {
				Log.v("mainActivity", "getFrage nicht erfolgreich");
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			intent.putExtra ("FragenID", fragenID);
			startActivity(intent);
		}
		
		else if (view == _buttonHilfe) {
			Intent intent = new Intent(this,HilfeActivity.class);
			startActivity(intent);
		}
		
		else return;
	}

}
